﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Data;

namespace TB_WS.ASMX
{
    /// <summary>
    /// Seller_Manage 的摘要说明
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务，请取消注释以下行。 
    // [System.Web.Script.Services.ScriptService]
    public class Seller_Manage : System.Web.Services.WebService
    {

       [WebMethod(Description ="查找卖家昵称详细信息")]
       public DataSet GET_SELLER_INFO(string Seller_Nick)
        {
            return Class.Seller_Manage.select_Seller_Info(Seller_Nick);
        }

       [WebMethod(Description ="新增商家信息")]
       public int INSERT_SELLER(string Seller_Nick, string Seller_PWD,
            string WeChat_AppID, string WeChat_AppSecret,
            string TB_AppKey, string TB_AppSecret,
            string TB_Session, string Last_TB_Session_Time)
        {
            int Seller_Nick_Count = Class.Seller_Manage.get_seller_count(Seller_Nick);
            if(Seller_Nick_Count>0)
            {
                return -1;
            }
            else
            {
                return Class.Seller_Manage.insert_Seller(Seller_Nick,
                    Seller_PWD, WeChat_AppID, WeChat_AppSecret, TB_AppKey,
                    TB_AppSecret, TB_Session, Last_TB_Session_Time);
            }
        }

        [WebMethod(Description = "登录校验")]
        public int LOGIN_CONFORM(string Seller_Nick, string Seller_PWD)
        {
            int Seller_Nick_Count = Class.Seller_Manage.get_seller_count(Seller_Nick);
            if(Seller_Nick_Count==0)
            {
                return -1;//没有这个商家
            }
            else
            {
                return Class.Seller_Manage.Login_Conform(Seller_Nick, Seller_PWD);
            }
        }

        [WebMethod(Description ="修改商家管理密码")]
        public int CHANGE_SELLER_PWD(string Seller_Nick, string Seller_PWD)
        {
            return Class.Seller_Manage.update_seller_PWD(Seller_Nick, Seller_PWD);
        }

        [WebMethod(Description = "修改微信公众号信息")]
        public int CHANGE_SELLER_WECHAT(string Seller_Nick,
            string WeChat_AppID, string WeChat_AppSecret)
        {
            return Class.Seller_Manage.update_seller_WeChat_Info(Seller_Nick,
                WeChat_AppID, WeChat_AppSecret);
        }

        [WebMethod(Description ="修改淘宝开放平台信息")]
        public int CHANGE_SELLER_TB_INFO(string Seller_Nick,
            string TB_AppKey, string TB_AppSecret)
        {
            return Class.Seller_Manage.update_seller_TB_Info(Seller_Nick,
                TB_AppKey, TB_AppSecret);
        }

        [WebMethod(Description ="更新淘宝SESSION信息")]
        public int CHANGE_SELLER_TB_SESSION(string Seller_Nick, string TB_Session)
        {
            return Class.Seller_Manage.update_Seller_Session(Seller_Nick,
                TB_Session);
        }

        [WebMethod(Description ="获取微信回复详情")]
        public DataSet GET_WXR_INFO(int Seller_id,string WXR_Type)
        {
            return Class.WX_Reply.get_WXR_Info(Seller_id, WXR_Type);
        }

        [WebMethod(Description ="更新微信自动回复")]
        public int UPDATE_WXR_INFO(int Seller_ID,string WXR_Type,string WXR_Str)
        {
            if (Class.WX_Reply.get_WXR_INFO_count(Seller_ID, WXR_Type) == 0)
            {
                return Class.WX_Reply.Insert_WX_Reply(Seller_ID, WXR_Type, WXR_Str);
            }
            else
            {
                return Class.WX_Reply.Update_WXR_Str(Seller_ID, WXR_Type, WXR_Str);
            }
        }

        [WebMethod(Description ="新增微信自动回复")]
        public int INSERT_WXR_INFO(int Seller_ID, string WXR_Type, string WXR_Str)
        {
            return Class.WX_Reply.Insert_WX_Reply(Seller_ID, WXR_Type, WXR_Str);
        }
        
    }
}
